package com.rocpenghua.design.composite;

import java.util.ArrayList;

/**
 * @author pengp
 * @date 2023年02月22日 11:05
 */
public class CompositePatternDemo {
    public static void main(String[] args) {
        Employee CEO = new Employee("John","CEO", 30000);

        Employee headSales = new Employee("Robert","Head Sales", 20000);

        Employee headMarketing = new Employee("Michel","Head Marketing", 20000);

        Employee clerk1 = new Employee("Laura","Marketing", 10000);
        Employee clerk2 = new Employee("Bob","Marketing", 10000);

        Employee salesExecutive1 = new Employee("Richard","Sales", 10000);
        Employee salesExecutive2 = new Employee("Rob","Sales", 10000);

        CEO.add(headSales);
        CEO.add(headMarketing);

        headSales.add(salesExecutive1);
        headSales.add(salesExecutive2);

        headMarketing.add(clerk1);
        headMarketing.add(clerk2);

        //打印该组织的所有员工
        CEO.operation();
        for (Component headEmployee : CEO.getAllChild()) {
            headEmployee.operation();
            for (Component employee : headEmployee.getAllChild()) {
                employee.operation();
            }
        }
    }
}
/**
 * Employee :[ Name : John, dept : CEO, salary :30000 ]
 * Employee :[ Name : Robert, dept : Head Sales, salary :20000 ]
 * Employee :[ Name : Richard, dept : Sales, salary :10000 ]
 * Employee :[ Name : Rob, dept : Sales, salary :10000 ]
 * Employee :[ Name : Michel, dept : Head Marketing, salary :20000 ]
 * Employee :[ Name : Laura, dept : Marketing, salary :10000 ]
 * Employee :[ Name : Bob, dept : Marketing, salary :10000 ]
 */